package com.binarysoft.service.common.hbase;

import java.util.Collection;

import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.Table;

import common.framework.dsb.DynamicService;

/**
 * HBase 连接池服务，提供对多个HBase集群的连接服务。 其核心接口是getHtable(String clusterName, String
 * tableName) 获取Table对象后，进行数据库表的查询、增加、删除、更新等操作，操作完成后一定要关闭Table。
 * 
 * @author David
 *
 */
public interface HBaseService extends DynamicService {

	/**
	 * Check HBase service is available.
	 * 
	 * @param clusterName
	 * @return
	 * @throws Exception
	 */
	boolean isAvailable(String clusterName) throws Exception;

	/**
	 * Get HBase table from HBase cluster. Note: Table must be closed while
	 * operation has been finished!!!
	 * 
	 * @param clusterName
	 *            HBase cluster name
	 * @param tableName
	 *            HBase table name
	 * @return Table
	 * @throws Exception
	 */
	Table getHtable(String clusterName, String tableName) throws Exception;

	/**
	 * List all table names.
	 * 
	 * @param clusterName
	 * @return All table names.
	 * @throws Exception
	 */
	Collection<String> listTableNames(String clusterName) throws Exception;

	/**
	 * Get table descriptor.
	 * 
	 * @param clusterName
	 * @param tableName
	 * @return
	 * @throws Exception
	 */
	HTableDescriptor getTableDescriptor(String clusterName, String tableName) throws Exception;

	/**
	 * List clusters
	 * 
	 * @return
	 * @throws Exception
	 */
	Collection<String> listClusters() throws Exception;

}
